import {expect} from 'chai'
import {describe} from 'mocha'
import * as redline from '../src/redline'
import process from "process";

describe('测试 redline check', () => {
    it('测试没有红线',  () => {
        redline.redlineCheck("ss","sasa",1,"ERROR")
    })
    it('测试有红线 大于返回false',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"ge","threshold":2}]');
        var result = redline.redlineCheckResult(redlines,"sasa",1);
        expect(result).equal(false)
    })

    it('测试有红线 大于返回true',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"ge","threshold":2.1}]');
        var result = redline.redlineCheckResult(redlines,"sasa",3);
        expect(result).equal(true)
    })

    it('测试有红线 小于返回true',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"le","threshold":2.1}]');
        var result = redline.redlineCheckResult(redlines,"sasa",1.1);
        expect(result).equal(true)
    })
    it('测试有红线 小于返回false',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"le","threshold":2.1}]');
        var result = redline.redlineCheckResult(redlines,"sasa",3);
        expect(result).equal(false)
    })
    it('测试有红线 等于返回true',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"eq","threshold":2.1}]');
        var result = redline.redlineCheckResult(redlines,"sasa",2.1);
        expect(result).equal(true)
    })
    it('测试有红线 等于返回false',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"eq","threshold":2.1}]');
        var result = redline.redlineCheckResult(redlines,"sasa",2.12);
        expect(result).equal(false)
    })
})


describe('测试 redline', () => {
    it('测试没有红线',  () => {
        redline.redlineCheck("ss","sasa",1,"ERROR")
    })
    it('测试有红线 ',  () => {
        let redlines = JSON.parse('[{"key":"sasa","type":"GE","threshold":2}]');
        process.env["CHECK_REDLINES"]='[{"key":"sasa","type":"GE","threshold":2}]'
        redline.redlineCheck(redlines,"sasa",1,"ERROR");
    })

})

describe('测试 报告', () => {
    it('测试报告',  () => {
        redline.reportResultUrl("http://aliyun.com")
    })


})